 "use strict";
require([
  './dev/layer',
  'polyfill',
  './dev/nav',
  './dev/menu',
  './dev/pagenations',
  './dev/banner'
], function (layer, polyfill, nav, menu, Pager, banner) {
  //layer.loadLayer();
  nav.showNav();
  //menu.showMenu();
  layer.showBox();
  

  (function(b) {
      b.fn.extend({
        "mouseMove": function(c) {
          const that = b(this);
          that.hover(function(k) {
            const u = b(this).find(c);
            const p = k.clientX;
            const n = k.clientY;
            const s = parseInt(b(this).offset().top);
            const o = parseInt(s + b(this).height());
            const g = parseInt(b(this).offset().left);
            const d = parseInt(g + b(this).width());
            const m = Math.abs(n - s);
            const j = Math.abs(n - o);
            const i = Math.abs(p - g);
            const f = Math.abs(p - d);
            const h = Math.min(m, j, i, f);
            const q = k.type;
            switch (h) {
              case m:
                a("top", q, u);
                break;
              case j:
                a("bottom", q, u);
                break;
              case i:
                a("left", q, u);
                break;
              case f:
                a("right", q, u)
            }
          })
        }
      });
      function a(c, d, f) {
        const e = 300;
        if (c == "top") {
          if (d == "mouseenter") {
            b(b(f)[0]).stop(true, true);
            b(b(f)[0]).css({
              display: "block",
              top: "-100%",
              left: "0"
            }).animate({
              top: 0,
              left: 0
            }, e)
          } else {
            b(b(f)[0]).animate({
              display: "block",
              top: "-100%",
              left: "0"
            }, e)
          }
        }
        if (c == "left") {
          if (d == "mouseenter") {
            b(b(f)[0]).stop(true, true);
            b(b(f)[0]).css({
              display: "block",
              top: "0",
              left: "-100%"
            }).animate({
              left: 0,
              top: 0
            }, e)
          } else {
            b(b(f)[0]).animate({
              display: "block",
              left: "-100%"
            }, e)
          }
        }
        if (c == "bottom") {
          if (d == "mouseenter") {
            b(b(f)[0]).stop(true, true);
            b(b(f)[0]).css({
              display: "block",
              top: "100%",
              left: "0"
            }).animate({
              top: 0,
              left: 0
            }, e)
          } else {
            b(b(f)[0]).animate({
              display: "block",
              top: "100%",
              left: "0"
            }, e)
          }
        }
        if (c == "right") {
          if (d == "mouseenter") {
            b(b(f)[0]).stop(true, true);
            b(b(f)[0]).css({
              display: "block",
              top: 0,
              left: "100%"
            }).animate({
              left: "0%",
              top: 0
            }, e)
          } else {
            b(b(f)[0]).animate({
              display: "block",
              left: "100%"
            }, e)
          }
        }
      }
    }
  )($);


layui.use('layer', () => { //独立版的layer无需执行这一句
    const $ = layui.jquery;
    $.getJSON("./data/listConf.json", (data) => {
        const i = window.location.href.split("/").length - 1;
        const lastName = window.location.href.split("/")[i].split(".")[0];
        $.each(data, (index, item) => {
          if (item.id === lastName) {
            Pager.pageFn(item.json, item.paginationId, item.dataShow)
          }
        });

      });
});



});
